%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%            带圈（带框）数字
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{zhmathstyle}


\RequirePackage{mathtools}
\RequirePackage{amssymb}
\DeclareMathSymbol{\gang}{\mathord}{AMSa}{"39}
\DeclareMathSymbol{\ratio}{\mathrel}{operators}{"3A}
\newcommand{\bi}{\mathrel{\raisebox{0.3mm}{$\ratio$}}}
\DeclareSymbolFont{pletter}{OML}{pxmi}{m}{it}
\SetSymbolFont{pletter}{bold}{OML}{pxmi}{bx}{it}
%\DeclareMathSymbol{v}{\ mathalpha}{pletter }{"76}
\DeclareMathSymbol{\alpha}{\mathalpha}{pletter}{"0B}
\DeclareMathSymbol{\beta}{\mathalpha}{pletter}{"0C}
\DeclareMathSymbol{\lambda}{\mathalpha}{pletter}{"15}
\DeclareMathSymbol{\mu}{\mathalpha}{pletter}{"16}

\DeclareSymbolFont{euletters}       {U}{zeur}{m}{n}
\DeclareMathSymbol{\piup}     {\mathalpha}{euletters}{"19}

\DeclareSymbolFont{pxletters}       {OML}{zplm}{m}{it}
\SetSymbolFont{pxletters}{bold}{OML}{zplm}{b}{it}
\DeclareMathSymbol{\gamma}{\mathalpha}{pxletters}{"0D}

\makeatletter
\DeclareFontFamily{U}{tipa}{}
\DeclareFontShape{U}{tipa}{m}{n}{<->tipa10}{}
\newcommand{\arc@char}{{\usefont{U}{tipa}{m}{n}\symbol{62}}}%

\newcommand{\wideparen}[1]{\mathpalette\arc@arc{#1}}

\newcommand{\arc@arc}[2]{%
	\sbox0{$\m@th#1#2$}%
	\vbox{
		\hbox{\resizebox{\wd0}{\height}{\arc@char}}
		\nointerlineskip
		\box0
	}%
}
\makeatother
%根指数位置的调整
\makeatletter

\newdimen\sqrtminh
\newdimen\sqrtmaxh
\sqrtminh=12.4pt
\sqrtmaxh=36.4pt
\newcount\rootpianyi

\def\r@@t#1#2{\setboxz@h{$\m@th#1\sqrtsign{#2}$}%
	%
	\dimen@\ht\z@\advance\dimen@\dp\z@
	\ifdim\dimen@>\sqrtminh
	\ifdim\dimen@<\sqrtmaxh
	\rootpianyi=3
	\fi\fi
	%
	\dimen@\ht\z@\advance\dimen@-\ht\rootbox
	\setbox\@ne\hbox{$\m@th#1\mskip\uproot@ mu$}%
	\advance\dimen@ by1.667\wd\@ne
	\mkern-\leftroot@ mu\mkern5mu
	\mkern\rootpianyi mu
	\raise\dimen@\copy\rootbox
	\mkern-\rootpianyi mu
	\mkern-11mu\mkern\leftroot@ mu
	\boxz@}

\makeatother

\DeclareFontFamily{OMX}{yhex}{}
\DeclareFontShape{OMX}{yhex}{m}{n}
{<->*[0.95]yhcmex10}{}
\DeclareSymbolFont{yhlargesymbols}{OMX}{yhex}{m}{n}
%\DeclareMathAccent{\wideparen}{\mathord}{yhlargesymbols}{"F3}
%\DeclareFontEncoding{LS1}{}{}
%\DeclareFontSubstitution{LS1}{stix}{m}{n}
%\DeclareSymbolFont{letters}       {LS1}{stix}     {m}{it}
%\SetSymbolFont{letters}     {bold}{LS1}{stix}     {b}{it}
%\DeclareMathSymbol{z}     {\mathalpha}{letters}  {`z}
\DeclareFontFamily{U}{matha}{\hyphenchar\font45}
\DeclareFontShape{U}{matha}{m}{n}{
	<5> <6> <7> <8> <8.5> <9.5>
	<10.5> matha10 <12> <14.4> <17.28> <20.74> <24.88> matha12
}{}
\DeclareSymbolFont{matha}{U}{matha}{m}{n}
\DeclareFontSubstitution{U}{matha}{m}{n}
\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
	<->*[0.95]
	mathx10
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareSymbolFont{cnmath}{TU}{SIMSUNGAI.TTF(0)}{m}{n}
\AtBeginDocument{
	\DeclareMathSymbol{,}{\mathord}{cnmath}{"2C}
	\DeclareMathDelimiter{(}{\mathopen} {cnmath}{"28}{mathx}{"00}
	\DeclareMathDelimiter{)}{\mathclose}{cnmath}{"29}{mathx}{'010}
	\DeclareMathDelimiter{[}{\mathopen}{cnmath}{"5B}{mathx}{'020}
	\DeclareMathDelimiter{]}{\mathclose}{cnmath}{"5D}{mathx}{'030}
	\DeclareMathDelimiter{\lbrace}{\mathopen}{cnmath}{"7B}{mathx}{'040}
	\DeclareMathDelimiter{\rbrace}{\mathclose}{cnmath}{"7D}{mathx}{'050}
	\DeclareMathSymbol{.}{\mathord}{cnmath}{"2E}
	\DeclareMathSymbol{:}{\mathord}{cnmath}{"3A}
	\DeclareMathSymbol{;}{\mathord}{cnmath}{"3B}
	\DeclareMathDelimiter{\lvert}{\mathopen}{cnmath}{"7C}{mathx}{'007}
	\DeclareMathDelimiter{\rvert}{\mathopen}{cnmath}{"7C}{mathx}{'007}
	
}


%\DeclareMathDelimiter{|}              {matha}{"7C}{mathx}{"07}
%\DeclareMathDelimiter{\langle}     {4}{matha}{"78}{mathx}{"40}
%\DeclareMathDelimiter{\rangle}     {5}{matha}{"79}{mathx}{"44}
%\DeclareMathAccent{\wideparen}    {0}{mathx}{"75}
%\DeclareMathDelimiter{\vert}       {0}{matha}{"7C}{mathx}{"07}{matha}{'077}{mathx}{"61}{symbols}{"70}
\DeclareMathRadical{\sqrtsign}{matha}{"3F}{yhlargesymbols}{"70}

\DeclareMathSymbol{\braceld}       {0}{mathx}{"68}
\DeclareMathSymbol{\bracemd}       {0}{mathx}{"69}
\DeclareMathSymbol{\bracerd}       {0}{mathx}{"6A}
\DeclareMathSymbol{\bracexd}       {0}{mathx}{"6B}
\DeclareMathSymbol{\bracelu}       {0}{mathx}{"6C}
\DeclareMathSymbol{\bracemu}       {0}{mathx}{"6D}
\DeclareMathSymbol{\braceru}       {0}{mathx}{"6E}
\DeclareMathSymbol{\bracexu}       {0}{mathx}{"6F}
%
% Borrowed from "newmath" by Matthias Clasen and Ulrik Vieth.
%
\makeatletter
\def\braceexwd{2mu}%
\def\bracevkern{0pt}%
%
% Remark: it seems that new horizontal braces may take
% into account vertical skip in their native design.
% We've followed this idea and not Knuth's construction.
% But we can add or sustract \bracevkern.
%
\def\bracefill#1#2#3#4{$\m@th
	#1#4\mkern-\braceexwd \cleaders\hbox{$#4$}\hfill
	\mkern-\braceexwd#4#2#4\mkern-\braceexwd
	\cleaders\hbox{$#4$}\hfill \mkern-\braceexwd#4#3$}%
%
\def\overbrace@#1#2{\mathop{\vbox{\m@th\ialign{##\crcr
				\noalign{\kern\bracevkern}
				#1\crcr\noalign{\kern\bracevkern\nointerlineskip}%
				$\hfil\displaystyle{#2}\hfil$\crcr}}}\limits}%
%
\def\underbrace@#1#2{\mathop{\vtop{\m@th\ialign{##\crcr
				$\hfil\displaystyle{#2}\hfil$\crcr
				\noalign{\kern\bracevkern\nointerlineskip}
				#1\crcr\noalign{\kern\bracevkern}}}}\limits}%
% user-level macros
\def\overbrace{\overbrace@{\bracefill\braceld\bracemd\bracerd\bracexd}}
\def\underbrace{\underbrace@{\bracefill\bracelu\bracemu\braceru\bracexu}}
\def\overgroup{\overbrace@{\bracefill\braceld{}\bracerd\bracexd}}
\def\undergroup{\underbrace@{\bracefill\bracelu{}\braceru\bracexu}}
\makeatother

%\DeclareSymbolFont{plargesymbols}{OMX}{mdugm}{m}{n}
%\DeclareMathAccent {\wideparen}{\mathord}{plargesymbols}{"F3}
\makeatletter
\def\upintkern@{\mkern-7mu\mathchoice{\mkern-2mu}{}{}{}}
\def\upintdots@{\mathchoice{\mkern-4mu\@cdots\mkern-4mu}%
	{{\cdotp}\mkern1.5mu{\cdotp}\mkern1.5mu{\cdotp}}%
	{{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}%
	{{\cdotp}\mkern1mu{\cdotp}\mkern1mu{\cdotp}}}
\newcommand{\upiint}{\DOTSI\protect\UpMultiIntegral{2}}
\newcommand{\upiiint}{\DOTSI\protect\UpMultiIntegral{3}}
\newcommand{\upiiiint}{\DOTSI\protect\UpMultiIntegral{4}}
\newcommand{\upidotsint}{\DOTSI\protect\UpMultiIntegral{0}}
\newcommand{\UpMultiIntegral}[1]{%
	\edef\ints@c{\noexpand\upintop
		\ifnum#1=\z@\noexpand\upintdots@\else\noexpand\upintkern@\fi
		\ifnum#1>\tw@\noexpand\upintop\noexpand\upintkern@\fi
		\ifnum#1>\thr@@\noexpand\upintop\noexpand\upintkern@\fi
		\noexpand\upintop
		\noexpand\ilimits@
	}%
	\futurelet\@let@token\ints@a
}
\makeatother

\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
	<->s * [0.9]
	mathx10
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathSymbol{\upintop}{\mathop}{mathx}{'273}
%\DeclareMathSymbol{\upiint}{\mathop}{mathx}{'274}
%\DeclareMathSymbol{\upiiint}{\mathop}{mathx}{'275}
\DeclareMathSymbol{\upointop}{\mathop}{mathx}{'276}
\DeclareMathSymbol{\upoiintop}{\mathop}{mathx}{'277}
\makeatletter
\newcommand{\upint}{\DOTSI\upintop\ilimits@}
\newcommand{\upoint}{\DOTSI\upointop\ilimits@}
\newcommand{\upoiint}{\DOTSI\upoiintop\ilimits@}

%\DeclareMathSymbol{\pm}            {2}{matha}{"08}
%\DeclareMathSymbol{\astt}    {0}{matha}{"07}
%\DeclareMathSymbol{\}         {2}{matha}{"07}
\RequirePackage{scalerel}
\def\depthgrowth{0.1pt}
\def\heightgrowth{1pt}
\newsavebox\zbox
\newcommand\zsqrt[1]{%
	\ignoremathstyle
	\savebox\zbox{$#1\rule{0pt}{.6\baselineskip}$}%
	\stretchrel*{\sqrt{\phantom{#1}\kern0.5pt}}%
	{\rule[-\dimexpr\dp\zbox+\depthgrowth]{0pt}{%
			\dimexpr\ht\zbox+\dp\zbox+\depthgrowth+\heightgrowth}}%
	\kern-\wd\zbox\textstyle#1%
}
\makeatletter
\ExplSyntaxOn
% emulate \mathmakebox in mathtools.sty
\providecommand*\mathmakeboxVar{%
	\@ifnextchar[  \MT_mathmakebox_var_I:w
	{\MT_mathmakebox_var_I:w[0pt]}}

\def\MT_mathmakebox_var_I:w[#1]{%
	\@ifnextchar[  {\MT_mathmakebox_var_II:w[#1]}
	{\MT_mathmakebox_var_II:w[#1][c]}}

\def\MT_mathmakebox_var_II:w[#1][#2]#3{%
	% script stype:        ratio = 4/5
	% script script style: ratio = 3/5
	\mathchoice
	{\MT_mathmakebox_var_III:w[#1][#2]\displaystyle{#3}}%
	{\MT_mathmakebox_var_III:w[#1][#2]\textstyle{#3}}%
	{\MT_mathmakebox_var_III:w[#1*4/5][#2]\scriptstyle{#3}}%
	{\MT_mathmakebox_var_III:w[#1*3/5][#2]\scriptscriptstyle{#3}}}
%  \mathpalette{\MT_mathmakebox_var_III:w[#1][#2]}}

\def\MT_mathmakebox_var_III:w[#1][#2]#3#4{%
	\@begin@tempboxa\hbox{$\m@th#3#4$}%
	\setlength\@tempdima{\dimexpr#1\relax}%
	\ifdim\@tempdima<\width
	\@tempdima=\width
	\fi
	\hbox{\hb@xt@\@tempdima{\csname bm@#2\endcsname}}%
	\@end@tempboxa}
\ExplSyntaxOff
\makeatother

% minimum width of fraction line:
%  - in text style: 1em
%  - in script style: 1em * 4/5
%  - in script script style: 1em * 3/5
\newcommand\xfrac[2]{%
	\frac{\mathmakeboxVar[1em]{#1}}{\mathmakeboxVar[1em]{#2}}
}

\DeclareRobustCommand{\zfrac}[2]{%
	\mathchoice{\displaystyle \frac{\raisebox{-0.2em}{$\mathmakeboxVar[1em]{#1}$}}{\raisebox{0.18ex}{$\mathmakeboxVar[1em]{#2}$}}}%
	{\displaystyle \frac{\raisebox{-0.2em}{$\mathmakeboxVar[1em]{#1}$}}{\raisebox{0.18ex}{$\mathmakeboxVar[1em]{#2}$}}}%
	{\frac{\mathmakeboxVar[1em]{#1}}{\mathmakeboxVar[1em]{#2}}}%
	{\frac{\mathmakeboxVar[1em]{#1}}{\mathmakeboxVar[1em]{#2}}}%
}
%%%定界符调整
\RequirePackage{relsize}
\newcommand\leftright[4][\displaystyle]{
	\setbox0=\hbox{$#1#3$}
	\setbox2=\hbox{$\vcenter{\copy0}$}
	\raisebox{\dimexpr\ht0 -\ht2}{$#1\left#2\copy2\right#4$}}
%%%集合
\providecommand\given{}
\newcommand\SetSymbol[1][]{%
	\nonscript\:#1\lvert
	\allowbreak
	\nonscript\:
	\mathopen {}}
\DeclarePairedDelimiterX\Set[1]\{\}{%
	\renewcommand\given{\SetSymbol[\delimsize]}
	#1
}
\endinput



